package com.thread.thread.Future;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.atomic.AtomicInteger;

public class FutureTest {
	static ExecutorService executorService= Executors.newFixedThreadPool(10);
	public static void main(String[] args) throws  Exception{

		AtomicInteger atomicInteger=new AtomicInteger(0);

		Callable<String> callable=new Callable<String>() {
			@Override
			public String call() throws Exception {
				return "菜菜"+atomicInteger.incrementAndGet();
			}
		};
		Future<String> callableFuture=executorService.submit(callable) ;

		Future<String> callableFuture1=executorService.submit(callable) ;

		System.out.println(callableFuture.get());
		System.out.println(callableFuture1.get());


		/*输出结果皆有可能，即线程已经有同步变异步
		菜菜2 菜菜1
		菜菜1 菜菜2	*/



	}

}
